# $Id: PKGBUILD 150550 2012-02-18 12:45:00Z pierre $
# Maintainer: Aaron Griffin <aaron@archlinux.org>
# Contributor: David Moore <davidm@sjsoft.com>

pkgname=slib
pkgver=3b3
pkgrel=2
pkgdesc="A library providing functions for Scheme implementations"
arch=('any')
url="http://people.csail.mit.edu/jaffer/SLIB.html"
license=('custom')
depends=('guile' 'sh' 'texinfo')
options=('emptydirs')
install=slib.install
source=("http://groups.csail.mit.edu/mac/ftpdir/scm/${pkgname}-${pkgver}.tar.gz")
md5sums=('11626eef380de4f56d3082514559beb6')

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  sed -r -i "s,/usr/(local/)?lib/slib,/usr/share/slib,g" *.init
  install -m755 -d "${pkgdir}/usr/share/slib"
  install -m644 *.scm *.init *.xyz *.txt *.dat *.ps "${pkgdir}/usr/share/slib/"
  install -m755 -d "${pkgdir}/usr/share/info"
  install -m644 slib.info "${pkgdir}/usr/share/info/"

  install -m755 -d "${pkgdir}/usr/bin"
  cat << _EOF > "${pkgdir}/usr/bin/slib"
#!/bin/sh
SCHEME_LIBRARY_PATH=/usr/share/slib/
export SCHEME_LIBRARY_PATH
VERSION=${pkgver}
S48_VICINITY="/usr/share/scheme48/"
export S48_VICINITY
_EOF

  cat slib.sh >> "${pkgdir}/usr/bin/slib"
  chmod 755 "${pkgdir}/usr/bin/slib"

  install -m755 -d "${pkgdir}/usr/share/man/man1"
  install -m644 slib.1 "${pkgdir}/usr/share/man/man1/"

  install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
  install -m644 COPYING "${pkgdir}/usr/share/licenses/$pkgname/"

  install -m755 -d "${pkgdir}/usr/share/guile/site/"
  ln -s /usr/share/slib "${pkgdir}/usr/share/guile/site/"
}
